#!/bin/sh

DAEMON_ARGS="-k -K 300 -R"
DROPBEAR_KEY_FILE="/etc/dropbear/dropbear_ed25519_host_key"

. /usr/share/common

start() {
	echo_title "Starting dropbear sshd"

	umask 077

	if [ ! -f $DROPBEAR_KEY_FILE ]; then
		dropbearkey -t ed25519 -f $DROPBEAR_KEY_FILE
	fi

	start_daemon
}

stop() {
	echo_title "Stopping dropbear sshd"

	stop_daemon
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		stop
		start
		;;
	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1
		;;
esac

exit $?
